package com.cnswhy.cloud.server.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnswhy.cloud.common.core.base.entity.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.cnswhy.cloud.common.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 商户基本信息
 * </p>
 *
 * @author cnswhy
 * @since 2021-03-17
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_merchant")
@ApiModel(value = "Merchant", description = "商户基本信息")
@AllArgsConstructor
public class Merchant extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 用户编号
     */
    @ApiModelProperty(value = "用户编号")
    @TableField("customer_id")
    @Excel(name = "用户编号")
    private Long customerId;

    /**
     * 商家名称
     */
    @ApiModelProperty(value = "商家名称")
    @Length(max = 100, message = "商家名称长度不能超过100")
    @TableField(value = "merchant_name", condition = LIKE)
    @Excel(name = "商家名称")
    private String merchantName;

    /**
     * 联系人
     */
    @ApiModelProperty(value = "联系人")
    @Length(max = 100, message = "联系人长度不能超过100")
    @TableField(value = "contacts", condition = LIKE)
    @Excel(name = "联系人")
    private String contacts;

    /**
     * 联系人手机号
     */
    @ApiModelProperty(value = "联系人手机号")
    @Length(max = 11, message = "联系人手机号长度不能超过11")
    @TableField(value = "contacts_tel", condition = LIKE)
    @Excel(name = "联系人手机号")
    private String contactsTel;

    /**
     * 客服电话
     */
    @ApiModelProperty(value = "客服电话")
    @Length(max = 20, message = "客服电话长度不能超过20")
    @TableField(value = "customer_service_phone", condition = LIKE)
    @Excel(name = "客服电话")
    private String customerServicePhone;

    /**
     * 有效期开始时间
     */
    @ApiModelProperty(value = "有效期开始时间")
    @TableField("expiry_start_date")
    @Excel(name = "有效期开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDate expiryStartDate;

    /**
     * 有效期结束时间
     */
    @ApiModelProperty(value = "有效期结束时间")
    @TableField("expiry_end_date")
    @Excel(name = "有效期结束时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDate expiryEndDate;

    /**
     * 商家状态1正常2待审核3审核不通过4禁用5删除6草稿
     */
    @ApiModelProperty(value = "商家状态1正常2待审核3审核不通过4禁用5删除6草稿")
    @NotNull(message = "商家状态1正常2待审核3审核不通过4禁用5删除6草稿不能为空")
    @TableField("status")
    @Excel(name = "商家状态1正常2待审核3审核不通过4禁用5删除6草稿")
    private Integer status;

    /**
     * 意向合作描述
     */
    @ApiModelProperty(value = "意向合作描述")
    @Length(max = 1000, message = "意向合作描述长度不能超过1000")
    @TableField(value = "cooperation_desc", condition = LIKE)
    @Excel(name = "意向合作描述")
    private String cooperationDesc;

    /**
     * 创建日期
     */
    @ApiModelProperty(value = "创建日期")
    @TableField("create_date")
    @Excel(name = "创建日期", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime createDate;

    /**
     * 审核日期
     */
    @ApiModelProperty(value = "审核日期")
    @TableField("audit_date")
    @Excel(name = "审核日期", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime auditDate;

    /**
     * 推荐人手机号码
     */
    @ApiModelProperty(value = "推荐人手机号码")
    @Length(max = 11, message = "推荐人手机号码长度不能超过11")
    @TableField(value = "recommender", condition = LIKE)
    @Excel(name = "推荐人手机号码")
    private String recommender;

    /**
     * 营业执照
     */
    @ApiModelProperty(value = "营业执照")
    @Length(max = 255, message = "营业执照长度不能超过255")
    @TableField(value = "license_url", condition = LIKE)
    @Excel(name = "营业执照")
    private String licenseUrl;

    /**
     * 经营许可证
     */
    @ApiModelProperty(value = "经营许可证")
    @Length(max = 255, message = "经营许可证长度不能超过255")
    @TableField(value = "management_license", condition = LIKE)
    @Excel(name = "经营许可证")
    private String managementLicense;

    @ApiModelProperty(value = "")
    @Length(max = 255, message = "长度不能超过255")
    @TableField(value = "address", condition = LIKE)
    @Excel(name = "")
    private String address;

    /**
     * 分成比例
     */
    @ApiModelProperty(value = "分成比例")
    @TableField("split_rate")
    @Excel(name = "分成比例")
    private Long splitRate;

    /**
     * 公共商家
     */
    @ApiModelProperty(value = "公共商家")
    @TableField("is_public")
    @Excel(name = "公共商家")
    private Integer isPublic;

    /**
     * 商家类型
     */
    @ApiModelProperty(value = "商家类型")
    @Length(max = 255, message = "商家类型长度不能超过255")
    @TableField(value = "merch_type", condition = LIKE)
    @Excel(name = "商家类型")
    private String merchType;

    /**
     * 身份证正面
     */
    @ApiModelProperty(value = "身份证正面")
    @Length(max = 255, message = "身份证正面长度不能超过255")
    @TableField(value = "idcard_front_url", condition = LIKE)
    @Excel(name = "身份证正面")
    private String idcardFrontUrl;

    /**
     * 身份证反面
     */
    @ApiModelProperty(value = "身份证反面")
    @Length(max = 255, message = "身份证反面长度不能超过255")
    @TableField(value = "idcard_back_url", condition = LIKE)
    @Excel(name = "身份证反面")
    private String idcardBackUrl;

    /**
     * 银行卡正面
     */
    @ApiModelProperty(value = "银行卡正面")
    @Length(max = 255, message = "银行卡正面长度不能超过255")
    @TableField(value = "bank_card_url", condition = LIKE)
    @Excel(name = "银行卡正面")
    private String bankCardUrl;

    @TableField(exist = false)
    private JSONObject jsonObject;
    /**
     * 商家类型
     */
    @ApiModelProperty(value = "添加类型")
    @Length(max = 255, message = "添加类型长度不能超过255")
    @TableField(value = "add_type")
    @Excel(name = "添加类型")
    private Integer addType;
    @Builder
    public Merchant(Long id, LocalDateTime createTime, LocalDateTime updateTime, Long createUser, Long updateUser, 
                    Long customerId, String merchantName, String contacts, String contactsTel, String customerServicePhone, 
                    LocalDate expiryStartDate, LocalDate expiryEndDate, Integer status, String cooperationDesc, LocalDateTime createDate, LocalDateTime auditDate, 
                    String recommender, String licenseUrl, String managementLicense, String address, Long splitRate, Integer isPublic, 
                    String merchType, String idcardFrontUrl, String idcardBackUrl, String bankCardUrl, Integer addType) {
        this.id = id;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.createUser = createUser;
        this.updateUser = updateUser;
        this.customerId = customerId;
        this.merchantName = merchantName;
        this.contacts = contacts;
        this.contactsTel = contactsTel;
        this.customerServicePhone = customerServicePhone;
        this.expiryStartDate = expiryStartDate;
        this.expiryEndDate = expiryEndDate;
        this.status = status;
        this.cooperationDesc = cooperationDesc;
        this.createDate = createDate;
        this.auditDate = auditDate;
        this.recommender = recommender;
        this.licenseUrl = licenseUrl;
        this.managementLicense = managementLicense;
        this.address = address;
        this.splitRate = splitRate;
        this.isPublic = isPublic;
        this.merchType = merchType;
        this.idcardFrontUrl = idcardFrontUrl;
        this.idcardBackUrl = idcardBackUrl;
        this.bankCardUrl = bankCardUrl;
        this.addType = addType;
    }

}
